// pages/me/merchantsAuthentication/merchantsAuthentication.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        id:null,
        legalPersonIdFacade:null,
        legalPersonIdBack:null,
        businessLicenseImg:null,
        licence:null,
        showTradePicker: false,
        tempTrade: null,
        form: {
            merchantsIndustry:null
          },
        dataList:[
            "餐饮美食",
            "其他"
        ]
    },
  openTradePicker: function () {
    this.setData({
      showTradePicker: true,
      tempTrade: this.data.dataList[0]
    })
  },
  bindChangeTrade: function (e) {
    var tempTrade = this.data.dataList[e.detail.value[0]];
    console.log(e, 9999)
    this.setData({
      tempTrade: tempTrade
    })
  },
  cancelChange: function (e) {
    this.setData({
      showTradePicker: false,
      tempTrade: null
    })
  },
  ensureChange: function (e) {
    let merchantsIndustry = 'form.merchantsIndustry'
    this.setData({
      showTradePicker: false,
      [merchantsIndustry]: this.data.tempTrade
    })
  },

    uploadImg() {
        let that = this
        const token = wx.getStorageSync('token');
        wx.chooseImage({
          count: 1,
          sourceType: ['album', 'camera'],
          success(res) {
            wx.showLoading({
              title: '正在上传',
            })
            let tempFilePaths = res.tempFilePaths
            if (res.tempFiles[0].size > 4096) {
              wx.hideLoading();
              wx.showToast({
                icon: 'none',
                title: '单张张片超过4M,请重新添加'
              });
              return
            } else {
              wx.uploadFile({
                url: baseUrl + '/app/upload', //仅为示例，非真实的接口地址
                filePath: tempFilePaths[0],
                header: { 'Authorization': token},
                name: 'files',
                formData: {},
                success(res) {
                  let data = JSON.parse(res.data)
                  wx.hideLoading();
                  let commodityImg = 'form.commodityImg'
                  that.setData({
                    [commodityImg]: data.data.path||''
                  })
                }
              })
          }
        }
        })
      },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})